window._STATUSCOLORCONFCHESS = {
	'增益':{word:'#47d6ff',nmb:'#0092BC'},
	'减益':{word:'#ff0000',nmb:'#DC143C'},
	'毒':{word:'#00be04',nmb:'#2E8B57'},
	'武':{word:'#fff000',nmb:'#DAA520'},
};

//五行免疫状态
window._FTYPESTATUSDEFEND={

    '金':{feng:1,ruo:1,nu:1},
    '木':{mian:1,du:1,huan:1},
    '水':{jiao:1,yun:1,jin:1},
    '火':{xiao:1,dong:1,ti:1},
    '土':{luan:1,kun:1,jue:1},
};


//负面效果 诅咒之躯随机出
window._DEBUFFARR = ['ruo','huan','du','yun','dong','kun','luan','jin','jiao','feng','mian','jue'];


window._STATUSCONFCHESS = {
        //主属性加50%
        'qiang':{name:'强',label:'增益',des:'主属性加50%'},
        //主属性减50%
        'ruo':{name:'弱',label:'减益',des:'主属性减50%'},
        //加速
        'ji':{name:'疾',label:'增益',des:'速度翻倍'},
        //减速
        'huan':{name:'缓',label:'减益',des:'速度减半'},	
        //中毒
        'du':{name:'毒',label:'毒',forever:1,des:'回合开始时候失去当前生命30%,上限99999999,永久存在'},
        //晕
        'yun':{name:'晕',label:'武',des:'无法行动'},
        //冰冻
        'dong':{name:'冻',label:'武',forever:1,des:'速度为0免疫伤害,永久存在,被攻击解除'},
        //捆绑 减移动
        'kun':{name:'困',label:'武',des:'移动为0'},
		//禁疗
        'jin':{name:'禁',label:'武',des:'无法恢复生命'},		
		//圣盾
        'dun':{name:'盾',label:'武',forever:1,des:'免疫伤害,永久存在,被攻击解除'},
        //被嘲讽
        'nu':{name:'怒',label:'武',des:'只会对状态来源进行普攻'},
        //混乱 普攻友军
        'luan':{name:'乱',label:'武',des:'普通攻击友军'},
        //封 被动失效
        'feng':{name:'封',label:'武',des:'被动技能失效'},
        //缴 装备失效
        'jiao':{name:'缴',label:'武',des:'装备失效'},
        //绝 受伤即死
        'jue':{name:'绝',label:'武',des:'受伤即死'},
        //狂 防御转换攻击 魔防转换精神
        'kuang':{name:'狂',label:'增益',des:'防御转换为攻击,魔防转换为精神'},
        //大 属性翻倍速度减半
        'da':{name:'大',label:'增益',des:'主属性翻倍速度减半'},
        //小 属性减半1速度翻倍
        'xiao':{name:'小',label:'减益',des:'主属性减半速度翻倍'},
        //虚 无法造成或受到物理和法术伤害
        'xu':{name:'虚',label:'武',des:'无法造成或受到物理和法术伤害'},
        //隐 无法成为普攻或者法术的目标
        'yin':{name:'隐',label:'武',des:'无法成为普攻或者法术的目标,攻击后解除'},
        //快 速度+100 
        'kuai':{name:'快',label:'增益',des:'速度+100'},
        //护 由状态来源承受伤害
        'hu':{name:'护',label:'武',forever:1,des:'由状态来源承受伤害,永久存在'},
        //替 将伤害转移给目标
        'ti':{name:'替',label:'毒',forever:1,des:'将伤害转移给目标,永久存在'},
        //魂 生命不会低于1
        'hun':{name:'魂',label:'武',des:'生命不会低于1'},
        //眠 无法行动 永久存在 受伤解除
        'mian':{name:'眠',label:'毒',forever:1,des:'无法行动,永久存在,受伤解除'},
};

window._STATUSHELPERCHESS = {

    //获取嘲讽单位
    getChaofenRole:function(){

        if(
            _CHESSFIGHT.currentPlayer
            &&_CHESSFIGHT.currentPlayer.chessStatus
            &&_CHESSFIGHT.currentPlayer.chessStatus.status=="nu"
        ){
            //return _CHESSFIGHT.currentPlayer.chessStatus.source;
            var sourceCode = _CHESSFIGHT.currentPlayer.chessStatus.sourceCode;
            return _CHESSFIGHT.getPlayerInfoByCode(sourceCode);
        }

        return null;

    },

    //判断角色是否可以行动
    canPlayerDoAction:function(player){

        if(player
            &&player.hp>0
            &&!_STATUSHELPERCHESS.hasStatus(player,'yun')
            &&!_STATUSHELPERCHESS.hasStatus(player,'mian')
        ){
            return true;
        }

        return false;

    },

    //根据状态修正角色属性
    resetRoleDataByStatus:function(player,roleData){

        if(player.chessStatus){

            var tmpstatus = player.chessStatus.status;

            if(tmpstatus=="qiang"){
                roleData.attack = Math.floor(roleData.attack*(1+_CS.buffper));
                roleData.defend = Math.floor(roleData.defend*(1+_CS.buffper));
                roleData.mattack = Math.floor(roleData.mattack*(1+_CS.buffper));
                roleData.mdefend = Math.floor(roleData.mdefend*(1+_CS.buffper));
            }else if(tmpstatus=="ruo"){
                roleData.attack = Math.floor(roleData.attack*(_CS.buffper));
                roleData.defend = Math.floor(roleData.defend*(_CS.buffper));
                roleData.mattack = Math.floor(roleData.mattack*(_CS.buffper));
                roleData.mdefend = Math.floor(roleData.mdefend*(_CS.buffper));
            }else if(tmpstatus=="ji"){
                roleData.speed = Math.floor(roleData.speed*(1+_CS.buffper));
            }else if(tmpstatus=="huan"){
                roleData.speed = Math.floor(roleData.speed*_CS.buffper);
            }else if(tmpstatus=="dong"){
                roleData.speed = 0;
            }else if(tmpstatus=="kun"){
                roleData.move = 0;
                roleData.distance = 1;
                roleData.scope = 0;
            }else if(tmpstatus=="da"){
                roleData.attack = roleData.attack*2;
                roleData.defend = roleData.defend*2;
                roleData.mattack = roleData.mattack*2;
                roleData.mdefend = roleData.mdefend*2;
                roleData.speed = Math.floor(roleData.speed/2);
            }else if(tmpstatus=="xiao"){
                roleData.attack = Math.floor(roleData.attack/2);
                roleData.defend = Math.floor(roleData.defend/2);
                roleData.mattack = Math.floor(roleData.mattack/2);
                roleData.mdefend = Math.floor(roleData.mdefend/2);
                roleData.speed = roleData.speed*2;
            }else if(tmpstatus=="kuai"){
                roleData.speed += 100;
            }else if(tmpstatus=="kuang"){
                roleData.attack += roleData.defend;
                roleData.defend = 0;
                roleData.mattack += roleData.mdefend;
                roleData.mdefend = 0;
            }
        }
    },

    addStatus:function(player,status,sourcePlayer){
        if(player){
            var hasclearBody = _ROLEDATA.getRealAttr(player,'clearBody');
            var ftype = player.ftype;
            var ftypedefend = _FTYPESTATUSDEFEND[ftype]
            //判断 净体 或者 五行免疫
            if(
                !hasclearBody
                &&(
                    !ftypedefend
                    ||!ftypedefend[status]
                )
            ){
                player.chessStatus = {
                    status:status,
                    sourceCode:sourcePlayer.code,
                    turn:3
                };
            }
        }
    },

    hasStatus:function(player,status){

        //显行
        if("yin"==status){
            if(
                _CHESSFIGHT
                &&_CHESSFIGHT.currentRoleData
                &&_CHESSFIGHT.currentRoleData.eye
            ){
                return false;
            }
        }

        return player
               &&player.chessStatus
               &&player.chessStatus.status==status;
    },


    checkAndReduceStatus:function(player,statusName){

        if(_STATUSHELPERCHESS.hasStatus(player,statusName)){

            player.chessStatus=null;

            return true;

        }

        return false;

    },

    reduceStatus:function(player){
        if(
           player
           &&player.chessStatus
           &&_STATUSCONFCHESS[player.chessStatus.status]
           &&!_STATUSCONFCHESS[player.chessStatus.status].forever
        ){
            player.chessStatus.turn--;
            if(player.chessStatus.turn<=0){
                player.chessStatus = null;
            }
        }
    },

    resetStatus:function(player){
        if(player){
            player.chessStatus = null;
        }
    },

    getStatusForShow:function(player){

        if(player
            &&player.chessStatus
            &&player.chessStatus.status
            &&_STATUSCONFCHESS[player.chessStatus.status]
        ){

            return {
                    color:_STATUSCOLORCONFCHESS[_STATUSCONFCHESS[player.chessStatus.status].label].word,
                    msg:_STATUSCONFCHESS[player.chessStatus.status].name
                    };

        }

        return null;

    }

}